package org.dlsu.mt.parser;

/**
 * FStructureElementValue represents an atomic value inside an FStructureElement.
 * This is a wrapper class for different kinds of values that wants to be used as atomic values for the FStructure.
 * This abstract class provides an implementation of the merge method which checks whether the two atomic values are equal
 * The class further requires the implementation of the clone(), equals(), hashCode(), toXML(), and toString() for all implementing subclasses.
 */
public abstract class FStructureElementValue {

	/**
	 * Creates a copy of the current FStructureElementValue.
	 * This is necessary during parsing and generation of the final FStructure
	 */
	public abstract Object clone();

	/**
	 * Compares whether two FStructureElementValue are the same.
	 * This is used in merge and other methods to check the consistency of atomic values.
	 *
	 * @param obj The target object to compare with
	 * @return True if the two element values are equal, false otherwise
	 */
	public abstract boolean equals(Object obj);

	/**
	 * The hashcode for this object.
	 * This is a necessary for the FStructureElement to properly store and retrieve this atomic value.
	 *
	 * @return The hash code of the element value
	 */
	public abstract int hashCode();

	/**
	 * Returns the XML representation of the FStructureElementValue.
	 * This is used in generating the XML output of the FStructure.
	 *
	 * @return The XML representation of the element value
	 */
	public abstract String toXML();

	/**
	 * Returns the String representation of the FStructureElementValue.
	 *
	 * @return The string representation of the element value
	 */
	public abstract String toString();

	/**
	 * Gets the value represented inside the FStructureElementValue
	 *
	 * @return The object represented in the element value
	 */
	public abstract Object getValue();

	/**
	 * Sets the value to be represented by the element value
	 *
	 * @param value The object to be represented
	 */
	public abstract void setValue(Object value);

	/**
	 * Implements merging as comparing the consistency of the two FStructureElementValues
	 *
	 * @param f The target FStructureElementValue to compare
	 * @return True if the two values are equivalent, false otherwise
	 */
	public boolean merge(FStructureElementValue f) {
		return f.equals(this);
	}

}